<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="com.yaodian100.core.common.utils.ServerValue"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@taglib uri="/WEB-INF/tld/pageutil.tld" prefix="pu"%>
<%@taglib uri="http://java.sun.com/jstl/core_rt" prefix="c-rt"%>
<%@taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt-rt"%>
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ include file="/taglibs.jsp"%>
${pu:reqSet('user', pu:user())}
<%--判斷訂單修改 --%>
<c-rt:set var="canChgPaymentIfo" value="N"/>
<c-rt:set var="canChgRecvInfo" value="N"/>

<c:choose>
	<c:when test="${order.paymentTp=='30' || order.paymentTp=='60'}">
		<c:if test="${order.orderSt=='00'}">
			<c-rt:set var="canChgPaymentIfo" value="Y"/>
			<c-rt:set var="canChgRecvInfo" value="Y"/>
		</c:if>
		<c:if test="${order.orderSt=='20' }">
			<c-rt:set var="canChgRecvInfo" value="Y"/>
		</c:if>
	</c:when>
	<c:otherwise>
		<c:if test="${order.paymentSt=='00' && order.orderSt == '10'}">		
			<c-rt:set var="canChgPaymentIfo" value="Y"/>					
			<c-rt:set var="canChgRecvInfo" value="Y"/>
		</c:if>
		<c:if test="${order.paymentSt=='10' && order.sync=='false' && order.orderSt == '20'}">
			<c-rt:set var="canChgRecvInfo" value="Y"/>
		</c:if>			          
	</c:otherwise> 
</c:choose>
<script type="text/javascript" charset="UTF-8" src="/js/jquery-ui-1.7.2.custom.min.js"></script>
<script type="text/javascript" charset="UTF-8" src="/js/jquery.alphanumeric.js"></script>
<link rel="stylesheet" type="text/css" href="/css/jquery-ui-1.7.2.custom.css"/>
<style>
.type-0,.type-1,.type-2,.type-3,.type-4,.type-5,.type-money{font-size:12px; padding:1px 3px;*padding:3px 3px 0;}
.type-0{display:none;} /* 主商品 */
.type-1{background:#FCF; color:#333;}/* 預購 */
.type-2{background:#94ebf2; color:#333;}/* 贈品 */
.type-3{background:#ffcc99; color:#333;}/* 加購 */
.type-4{background:#d5f091; color:#333;}/* 活動 */
.type-5{ background:#FF0; color:#333; }/* 满额购 */
.type-6{background:#d5f091; color:#333;}/* 活動 */
</style>


<h1>完成修改订单及运费</h1>
<font color="#ff3300">
<s:actionerror />
<s:actionmessage />
<s:fielderror />
</font>
<div class="f-link">
<c-rt:if test="${pu:substring(user.group.code, 0, 1)!='C'}"><a href="/ecadmin/order/search.do">回订单查询页</a></c-rt:if>
<c-rt:if test="${pu:substring(user.group.code, 0, 1)=='C'}"><a href="/ecadmin/crmQuery/search.do">回CRM 查询</a></c-rt:if>
</div>
<br><table width="100%" border="1" cellspacing="0" cellpadding="0" class="tb-data">
  <tr>
    <td height="30" align=left><b>订单编号：</b> ${order.orderId}<br/>
    <c-rt:if test="${order.orderSt=='80' || order.orgOrderId!=null}">
    	<c-rt:if test="${order.orderSt=='80'}">
    	
    		${pu:reqSet('hqlMFK', 'from Orders where orgOrderId=?') }
    		${pu:listAdd('orderFKParams', order.orderId) }
    		${pu:reqSet('theOrdersFK', pu:queryByHql(hqlMFK, pu:arrayGet('orderFKParams'), null)) }
    		<c-rt:if test="${theOrdersFK !=null}">
    		(新成立订单：<a href="/ecadmin/order/view.do?orderId=${theOrdersFK[0].orderId }" target="_blank">${theOrdersFK[0].orderId }</a>)<br/>
    		</c-rt:if>
    	</c-rt:if>
    	<c-rt:if test="${order.orgOrderId!=null}">
    		(原订单：<a href="/ecadmin/order/view.do?orderId=${order.orgOrderId }" target="_blank">${order.orgOrderId }</a>)<br/>
    	</c-rt:if>
    
    </c-rt:if>
    
    <b>会员编号：</b>${order.memberId } </td>
    <td align=left><b>订购人：</b><a href='../member/view.do?memberId=${order.memberId}'>${order.memberName}</a></td>
    <td align=left><b>订单状态：
    	<c:if test="${empty cancelServiceOrders}">${orderStMenu.options[order.orderSt].name}</c:if>
    	<c:if test="${!empty cancelServiceOrders}">
    	<a href="<c-rt:url value="/serviceOrder/page.do?iamlazy=detail&from=list&serviceId=${cancelServiceOrders[0].serviceId}"/>">${orderStMenu.options[order.orderSt].name}</a>
    	</c:if></b>
    				<c-rt:if test="${order.orderSt=='00'}"><br/>
						<input name="按鈕" type="button" value="审核失敗" id="updOrdSt_${order.orderId}_82"/>
						<input name="按鈕" type="button" value="等待配貨" id="updOrdSt_${order.orderId}_20"/>
					</c-rt:if>
					<c-rt:if test="${order.paymentTp=='30'&&order.orderSt=='00'}">
						<br><input name="按鈕" type="button" value="联络不到简讯通知" id="sendSms_${order.orderId}_${fn:trim(order.receiverMobile)}"/>
					</c-rt:if>
					
					<c-rt:if test="${order.orderSt=='80' || order.orderSt=='81'}">
						<br/>取消时间：<fmt-rt:formatDate value="${order.modifyDate}" pattern="yyyy-MM-dd HH:mm"/>
					</c-rt:if>
    </td>
    <td align=left><b>订购日期：</b><fmt:formatDate pattern="yyyy-MM-dd HH:mm:ss" value="${order.orderDt}" /></td>
  </tr>
  <tr>
    <td height="30" align=left><b>付款方式：</b>${paymentTpMenu.options[order.paymentTp].name} (<a href="<c:url value="/order/viewChangeLog.do?orderId=${order.orderId}&logTp=chgPaymentTp"/>" >查看历程</a>)</td>
    <td align=left><b>付款状态：</b>${paymentStMenu.options[order.paymentSt].name}</td>
    <td align=left><b>订单来源：</b>${order.channel}<br><b>网站：</b>${domainSrc.options[order.domainSrc].name}</td>
    <td align=left><b>付款期限：</b><font color="#ff3300">
   	<c-rt:if test="${order.paymentTp!='30'}">
    <fmt:formatDate pattern="yyyy-MM-dd HH:mm:ss" value="${order.deadline}" />
    </c-rt:if>
    </font></td>
  </tr>
  <tr>
    <td height="30" align=left><b>收件人：${order.receiverName} (<a href="<c:url value="/order/viewChangeLog.do?orderId=${order.orderId}&logTp=chgRecvInfo"/>" >查看历程</a>)</td>
    <td colspan="${order.receiverTp=='30'?2:3 }" align=left>行動：${order.receiverMobile}<br />
    固定：${order.receiverPhoneArea}-${order.receiverPhone}-${order.receiverExt}<br />
    地址：(${order.receiverZip})${order.receiverProvince}${order.receiverCity}${order.receiverArea}${order.receiverAddr}
    <c:if test="${order.receiverTp=='30'}"><a href="<c:url value="/dpn/queryStore.do?dpnStoreId=${order.storeId} "/>" target="_blank">店点资讯</a>   
	<img src="/images/daphne/daphne.gif"></c:if>
    </td>
    <c:if test="${order.receiverTp=='30'}">
    <td>    
	运送方式:達芙妮到店取貨<br />
	到店日期: <c-rt:if test="${!empty order.logisticFinalDt}"><fmt-rt:formatDate value="${order.logisticFinalDt }" pattern="yyyy-MM-dd HH:mm:ss"/></c-rt:if>
          <c-rt:if test="${empty order.logisticFinalDt }">--</c-rt:if> <br />
	签收日期: <c-rt:if test="${!empty order.logisticSignDt}"><fmt-rt:formatDate value="${order.logisticSignDt }" pattern="yyyy-MM-dd HH:mm:ss"/></c-rt:if>
          <c-rt:if test="${empty order.logisticSignDt }">--</c-rt:if> <br />
	</td>
    
	</c:if>
	
  </tr>
  <tr>
    <td height="30" align=left><b>訂單類型：${order.orderType==1?'一般':'SCM'}</td>
    <td colspan="3" align=left>轉單供應商：${supplierApply.companyName}</td>
  </tr>
  <tr>
    <td height="30" colspan="5" valign="top" align=left><b>备注</b><BR>
　　<textarea name=memo cols="70" rows="5">${order.memo}</textarea></td>
  </tr>
<c:if test="${order.campaign}">
  <tr height="30">
    <td colspan="5" align=left>活动：</td>
  </tr>
</c:if>
</table>
<b><BR />
訂單重量
</b><BR />
<table width="100%" class="tb-data" border="1" cellpadding="0" cellspacing="0">
  <tr>
    <td height="30"><b>訂單重量：</b><fmt-rt:formatNumber value="${(order.totalWeight+0.001)/1000 }"  pattern="#,#0.00#"/>KG</td>
  </tr>
</table>
<b><br /> 
<b>付款资讯</b><br />
<table width="100%" class="tb-data" border="1" cellpadding="0" cellspacing="0">
  <tr class="bg-yl">
    <td height="30" align="left" colspan="2">付款日期：<b><font color="#ff3300"><fmt:formatDate pattern="yyyy-MM-dd HH:mm:ss" value="${order.paymentDt}" /></font></b></td>
    <td height="30" align="left" colspan="3">已付金额：<b><font color="#ff3300"><fmt:formatNumber value="${order.cash}" pattern="#####0.0"/></font></b></td>
  </tr>
  <tr class="bg-yl">
	  <td height="30" align="left">已退金额：<b><font color="#ff3300"><fmt:formatNumber value="${order.returnCash}" pattern="#####0.0"/></font></b></td>
    <td height="30" align="left">已退积分：<c-rt:if test = "${not empty order.orderBonusCampaign}">${order.bonus*order.orderBonusCampaign.offsetRate}</c-rt:if><c-rt:if test = "${empty order.orderBonusCampaign}">0</c-rt:if></td>
    <td align="left">已退我的帐户：<fmt:formatNumber value="${order.returnMyWallet}" pattern="#####0.0"/></td>
    <td align="left">已退我的礼品卡：<fmt:formatNumber value="${order.returnGiftcardBalance}" pattern="#####0.0"/></td>
    <td align="left">退款日期：<c-rt:if test="${order.returnCash!=0 || order.returnBonus!=0 || order.returnMyWallet!=0 || order.returnGiftcardBalance !=0}"><fmt:formatDate value="${order.modifyDate }" pattern="yyyy-MM-dd"/></c-rt:if></td>
  </tr>
</table>
<br /> 
<B>订购内容</B>
<br/>
<form name="orderForm" id="orderForm" method="POST" action="/ecadmin/order/updateOrderAndShipfare.do">
<input type="hidden" name="${order.orderId}">
<table width="100%" border="1" cellpadding="0" cellspacing="0" class="tb-1">
	<thead>
	<tr>
	 <th>商品编号</th>
   <th height="30">商品</th>
    <th>重量</th>
    <th>数量</th>
    <th>单价</th>
    <th>coupon</th>
    <th>小计</th>
    <th>合计</th>
	</tr>
	</thead>
	<c:forEach items="${order.orderProduct}" var="oproduct">
		${pu:reqSet('productWeight', 0) }
		<c:forEach items="${oproduct.orderProductDetail}" var="opdetail">
			<c:set var="productWeight" value="${productWeight+opdetail.unitWeight*opdetail.qty}" scope="request"/>
		</c:forEach>

		${pu:listAdd('weightList', productWeight) }
	</c:forEach>
<c:forEach items="${order.orderProduct}" var="oproduct" varStatus="row_index">
<c:if test="${oproduct.prodTp!='2'}">
  <tr class="${row_index.count % 2 == 0 ? 'bg-yl' : ''}"><!-- 主商品 -->
  	<td> ${oproduct.prodId}<a href="<%=ServerValue.getFrontHostname()%><%=ServerValue.getFrontContextPath()%>/product/product.do?productId=${oproduct.prodId}" target="blank">开启</a><br>
  	<c-rt:if test="${fn:contains(snapShots,oproduct.prodId)}">
  	<a href="<c-rt:url value="/resource/${order.orderId}_${oproduct.prodId}_${oproduct.prodTp}.jpg?memberId=${order.memberId}"/>" target="blank">商品快照</a>
  	</c-rt:if>
  	</td>
    <td height="30" style="text-align:left;">
<span class="type-${oproduct.prodTp}">${detailTpMenu.options[oproduct.prodTp].name}</span> ${oproduct.prodName}<c:if test="${oproduct.prodTp!=6}">－<b>[${oproduct.prodSpecName}]</b></c:if>

<br/>


<br/>

<%try{ %>

<c-rt:forEach items="${oproduct.applyCampaigns}" var="ac">
	          	
	          	<p>
	          	<c-rt:if test="${ac.active}">
	          		<span class="type-4" style="color:red">优惠</span>
	          	</c-rt:if>
	          	<c-rt:if test="${!ac.active}">
	          		<span class="type-6"  style="color:gray">优惠</span>（不符合）
	          	</c-rt:if>
	          <c-rt:if test="${ac.campaignUrl!=null}">
	          	<a target="_blank" class="a-red" href="${ac.campaignUrl }">${ac.campaignName }</a>
	          	</c-rt:if>
	          	<c-rt:if test="${ac.campaignUrl==null}">
	          	
	          	${pu:reqSet('pc', pu:get('com.yaodian100.ec.campaign.entity.Campaign', ac.campaignUuid)) }
	          	
	          	${ac.campaignName }
	          	
	          	</c-rt:if>
	          	</p>
	          	</c-rt:forEach>

<%}catch(Exception e){
    e.printStackTrace();
    
    }%>

    </td>
    <td>
	    <c:forEach items="${oproduct.orderProductDetail}" var="opdetail" varStatus="rowdetail_index">
			<c:if test="${oproduct.prodSeq == opdetail.prodSeq }">
				<c:if test="${opdetail.detailTp == '0' || opdetail.detailTp == '1' || opdetail.detailTp == '5' || (opdetail.detailTp == '6' && opdetail.prodId == oproduct.prodId)}">
		    		<fmt-rt:formatNumber value="${(opdetail.unitWeight+0.001)/1000}"  pattern="#,#0.00#"/>
		    	 </c:if>
		    </c:if>
		</c:forEach>
    </td>
    <td>${oproduct.qty}</td>
    <td><fmt:formatNumber value="${oproduct.unitPrice}" pattern="#,###,##0.0"/></td>
    <td><fmt:formatNumber value="${oproduct.coupon}" pattern="#,###,##0.0"/></td>
    <td><fmt:formatNumber value="${oproduct.unitPrice*oproduct.qty}" pattern="#,###,##0.0"/></td>
    <td><fmt:formatNumber value="${oproduct.totalPrice}" pattern="#,###,##0.0"/></td>
  	</tr>
  </c:if>
  <c:forEach items="${oproduct.orderProductDetail}" var="opdetail" varStatus="rowdetail_index">
<c:if test="${oproduct.prodSeq == opdetail.prodSeq }">
<c:if test="${opdetail.detailTp != '0' && opdetail.detailTp != '1' && opdetail.detailTp != '5' && !(opdetail.detailTp == '6' && opdetail.prodId == oproduct.prodId)}">
  <tr class="${row_index.count % 2 == 0 ? 'bg-yl' : ''}"><!-- 明细 -->
  <td><a href="<%=ServerValue.getFrontHostname()%><%=ServerValue.getFrontContextPath()%>/product/product.do?productId=${opdetail.prodId}" target="blank"> ${opdetail.prodId}</a>
  <br><c-rt:if test="${fn:contains(snapShots,opdetail.prodId)}">
  	<a href="<c-rt:url value="/resource/${order.orderId}_${opdetail.prodId}_${opdetail.detailTp}.jpg?memberId=${order.memberId}"/>" target="blank">商品快照</a>
  	</c-rt:if>
  </td>
    <td height="30" style="text-align:left;">
<span class="type-${opdetail.detailTp}">${detailTpMenu.options[opdetail.detailTp].name}</span> ${opdetail.prodName}－<b>[${opdetail.prodSpecName}]</b>
<c-rt:if test="${order.orderSt=='35' && oproduct.prodStatus!='1' && oproduct.prodStatus!='2'&& oproduct.prodTp=='2'}">
[ <a href="/ecadmin/serviceOrder/toReturnProduct.do?orderProdId=${oproduct.orderProdId }">退货</a> ｜ <a href="/ecadmin/serviceOrder/toChangeProduct.do?orderProdId=${oproduct.orderProdId }">换货</a> ]
</c-rt:if>
    </td>
    <td><fmt-rt:formatNumber value="${(opdetail.unitWeight+0.001)/1000}"  pattern="#,#0.00#"/></td>
    <td>${opdetail.qty}</td>    
    <td><fmt:formatNumber value="${opdetail.unitPrice}" pattern="#,###,##0.0"/></td>
    <td>--</td>
    <td><fmt:formatNumber value="${opdetail.amount}" pattern="#,###,##0.0"/></td>
    <td>--</td>
  </tr>
  
</c:if>
 
</c:if>


</c:forEach>
</c:forEach>
</table>
<table width="100%">
<tr>
<td width="50%" valign="top">
<table width="100%">
<tr class="tb-R bg-yl">
	<th height="30" colspan="13">原订单</th>
</tr>
  <tr class="tb-R bg-yl">
    <td height="30" colspan="13">商品总额：<fmt:formatNumber value="${order.totalPrice}" pattern="#,###,##0.0"/></td>
  </tr>
  <tr class="tb-R bg-yl">
    <td height="30" colspan="13">－折抵优惠：<fmt:formatNumber value="${order.discount}" pattern="#,###,##0.0"/></td>
  </tr>
  <tr class="tb-R bg-yl">
    <td height="30" colspan="13">－－－－－－－－－－－－－－－－－－－－－－－－－</td>
  </tr>
  <tr class="tb-R bg-yl">
    <td height="30" colspan="13">＝合计金额：<fmt:formatNumber value="${order.amount}" pattern="#,###,##0.0"/></td>
  </tr>
  <tr class="tb-R bg-yl">
    <td height="30" colspan="13">＋运费：<fmt:formatNumber value="${order.shipfare}" pattern="#,###,##0.0"/>
    </td>
  </tr>
  <tr class="tb-R bg-yl">
    <td height="30" colspan="13">＋货到付款手续费：<fmt:formatNumber value="${order.codFee}" pattern="#,###,##0.0"/></td>
  </tr>      
  <tr class="tb-R bg-yl">
    <td height="30" colspan="13">－折扣礼券：<fmt:formatNumber value="${order.coupon}" pattern="#,###,##0.0"/></td>
  </tr>
  <tr class="tb-R bg-yl">
    <td height="30" colspan="13">－积分 <c-rt:if test = "${not empty order.orderBonusCampaign}">${order.bonus*order.orderBonusCampaign.offsetRate}</c-rt:if><c-rt:if test = "${empty order.orderBonusCampaign}">0</c-rt:if> 折抵：<fmt:formatNumber value="${order.bonus}" pattern="#,###,##0.0"/></td>
  </tr>
  <tr class="tb-R bg-yl">
    <td height="30" colspan="13">－－－－－－－－－－－－－－－－－－－－－－－－－</td>
  </tr>
  <tr class="tb-R bg-yl">
    <td height="30" colspan="13">＝订单金额：<fmt:formatNumber value="${order.totalPrice - order.discount  + order.shipfare  + order.codFee - order.coupon - order.bonus}" pattern="#,###,##0.0"/></td>
  </tr>
  <tr class="tb-R bg-yl">
    <td height="30" colspan="13">－礼品卡支付：<fmt:formatNumber value="${order.giftcardBalance}" pattern="#,###,##0.0"/></td>
  </tr>  
  <tr class="tb-R bg-yl">
    <td height="30" colspan="13">－账户余额支付：<fmt:formatNumber value="${order.myWallet}" pattern="#,###,##0.0"/></td>
  </tr>
  <tr class="tb-R bg-yl">
    <td height="30" colspan="13">－－－－－－－－－－－－－－－－－－－－－－－－－</td>
  </tr>
  <tr class="tb-R bg-yl">
    <td height="30" colspan="13">＝剩余应付金额：<b><font color="#ff3300"><fmt:formatNumber value="${order.mustPay}" pattern="#,###,##0.0"/></font></b></td>
  </tr>
</table>
</td>
</tr>
</table>
</form>
<div class="f-link">
	<c-rt:if test="${not empty pop}"><a href="javascript:window.close()">关闭视窗</a> / </c-rt:if><c-rt:if test="${pu:substring(user.group.code, 0, 1)!='C'}"><a href="/ecadmin/order/search.do">回订单查询页</a></c-rt:if><c-rt:if test="${pu:substring(user.group.code, 0, 1)=='C'}"><a href="/ecadmin/crmQuery/search.do">回CRM 查询</a></c-rt:if>
</div>
